package com.gujiangbo.application.common.fc;

import java.util.concurrent.Semaphore;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class CleanSemaphoreTask extends Thread {
	private static Log debugLog = LogFactory.getLog(FlowControlManage.class);
	private Semaphore conSem;
	private int taskTime;
	private int limtCount;

	public void run() {
		try {
			for (;;) {
				sleep(this.taskTime);

				this.conSem.release(this.limtCount - this.conSem.availablePermits());
			}
		} catch (Exception e) {
			debugLog.error("release exception:", e);
		}
	}

	public Semaphore getConSem() {
		return this.conSem;
	}

	public void setConSem(Semaphore conSem) {
		this.conSem = conSem;
	}

	public int getTaskTime() {
		return this.taskTime;
	}

	public void setTaskTime(int taskTime) {
		this.taskTime = taskTime;
	}

	public int getLimtCount() {
		return this.limtCount;
	}

	public void setLimtCount(int limtCount) {
		this.limtCount = limtCount;
	}
}
